package com.qiqu.controller;

import com.qiqu.entity.Comments;
import com.qiqu.entity.UsersReport;
import com.qiqu.service.UsersReportService;
import com.qiqu.utils.JSONResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UsersReport)表控制层
 *
 * @author makejava
 * @since 2021-04-12 20:47:36
 */
@RestController
@RequestMapping("usersReport")
@Api(value = "举报相关接口",tags = {"举报相关接口controller"})
public class UsersReportController {
    @Resource
    private UsersReportService usersReportService;
    //添加举报信息
    @ApiOperation(value = "添加举报信息--sora", notes = "添加举报信息")
//    @ApiImplicitParam(name = "report", value = "举报信息的json对象", required = true, dataType = "usersreport", paramType = "query")
    @PostMapping("/addReport")
    public JSONResult addReport(@RequestBody UsersReport report) {
        return new JSONResult(JSONResult.ok(usersReportService.addReport(report)));
    }

    //获取所有举报列表
    @ApiOperation(value = "获取所有举报信息--sora", notes = "获取所有举报信息")
    @GetMapping("/allReport")
    public JSONResult getAllReport() {
        return new JSONResult(JSONResult.ok(usersReportService.getAllReport()));
    }

    //获取单个举报信息
    @ApiOperation(value = "通过主键查询举报信息--sora", notes = "通过主键查询举报信息")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, dataType = "string", paramType = "query")
    @GetMapping("/queryById")
    public JSONResult queryById(@RequestParam("id") String id) {
        return new JSONResult(JSONResult.ok(usersReportService.queryById(id)));
    }

//    @ApiOperation(value = "通过文章id查询举报信息--sora", notes = "通过文章id查询举报信息")
//    @ApiImplicitParam(name = "reportId", value = "要查询文章的标题", required = true, dataType = "string", paramType = "query")
//    @GetMapping("/queryById")
//    public JSONResult queryByTitle(@RequestParam("reportId") String reportId) {}
//
//    public JSONResult queryReportId() {}

    //处理举报信息
    @ApiOperation(value = "删除举报记录--sora", notes = "删除举报记录")
    @ApiImplicitParam(name = "reportId", value = "想删除的举报记录的id", required = true, dataType = "string", paramType = "query")
    @GetMapping("/deleteReport")
    public JSONResult deleteReport(@RequestParam("reportId") String reportId){
        System.out.println("controller");
        return new JSONResult(JSONResult.ok(usersReportService.deleteReport(reportId)));
    }

    @ApiOperation(value = "删除被举报文章--sora", notes = "删除被举报文章")
    @ApiImplicitParam(name = "reportId", value = "被举报记录的id", required = true, dataType = "string", paramType = "query")
    @GetMapping("/deleteArticle")
    public JSONResult deleteArticle(@RequestParam("reportId") String reportId){
        return new JSONResult(JSONResult.ok(usersReportService.deleteArticle(reportId)));
    }




}